<?
require_once('common.inc.php');
require_once(_INC_PATH.'database.php');

$searchKey = urldecode(trim($_REQUEST['searchKey']));
$searchType = trim($_REQUEST['searchType']);
if($searchType == "address"){
	$where = " where address like '%$searchKey%'";
}else{
	$where = " where name like '%$searchKey%'";
}

$db = new database();
$sql = "select * from tbl_corporation $where limit 10";
$db->setQuery($sql);
$data = $db->loadList();

if(!empty($data))
{
	$returnArr = array();
	foreach($data as $key=>$value)
	{
		$returnArr[] = $value['name']."#|#"._HOST_ROOT."/corporation/".$value['id'].".html";
	}
	echo json_encode($returnArr);
}else{
	echo $sql;
}
die;
?>